<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="common/include :: header('养修服务单项列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="serviceItem-form">
					<div class="select-list">
						<ul>
							<li>
								服务项名称：<input type="text" name="serveName"/>
							</li>
							<li>
								服务分类：
								<select name="serveClassify" th:with="type=${@dict.getType('si_service_catalog')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:serviceItem:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
				<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="business:serviceItem:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="business:serviceItem:remove">
		            <i class="fa fa-remove"></i> 删除
		        </a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="business:serviceItem:export">
		            <i class="fa fa-download"></i> 导出
		        </a>
				<a class="btn btn-warning auditBtn" onclick="startAudit()" >
					<i class="fa fa-download"></i> 发起审核
				</a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="common/include :: footer" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('business:serviceItem:edit')}]];
		var removeFlag = [[${@permission.hasPermi('business:serviceItem:remove')}]];

		var carPackageDatas = [[${@dict.getType('si_car_package')}]];
		var serviceCatalogDatas = [[${@dict.getType('si_service_catalog')}]];
		var auditStatusDatas = [[${@dict.getType('si_audit_status')}]];
		var saleStatusDatas = [[${@dict.getType('si_sale_status')}]];

		var prefix = ctx + "/business/serviceItem";
		$(function() {
		    var options = {
		        url: prefix + "/query",
		        createUrl: prefix + "/addPage",
		        updateUrl: prefix + "/editPage?id={id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        sortName: "seq",
		        modalName: "养修服务单向",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'id',
		            title: '养修服务单向id',
					visible: false
		        },
		        {
		            field: 'name',
		            title: '服务项名称',
		            sortable: true
		        },

		        {
		            field: 'originalPrice',
		            title: '服务项原价',
		            sortable: true
		        },
		        {
		            field: 'discountPrice',
		            title: '服务项折扣价',
		            sortable: true
		        },
				{
					field: 'carPackage',
					title: '是否套餐',
					sortable: true,
					formatter: function(value, row, index) {
						//判断value是否与datas对比
						return $.table.selectDictLabel(carPackageDatas, value ? 1 : 0);
					}
				},
				{
					field: 'info',
					title: '备注信息',
					sortable: true,
					formatter: function(value, row, index) {
						//tooltip显示内容的长度
						return $.table.tooltip(value,30);
					}
				},
				{
					field: 'serviceCatalog',
					title: '服务分类',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(serviceCatalogDatas,value)
					}
				},
				{
					field: 'auditStatus',
					title: '审核状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(auditStatusDatas,value)
					}
				},
				{
					field: 'saleStatus',
					title: '上架状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(saleStatusDatas,value)
					}
				},
		        {
		            title: '操作',
		            align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editBtnFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')">' +
								'<i class="fa fa-edit"></i>编辑</a> ');
						if(row.saleStatus){
							actions.push('<a class="btn btn-danger btn-xs '+saleOffBtnFlag+'" href="javascript:void(0)" onclick="saleOff(\'' + row.id + '\')"><i class="fa fa-remove"></i>下架</a>');
						}else{
							if(row.carPackage==1 && row.auditStatus!=2){
								saleOnBtnFlag += " disabled";
							}
							actions.push('<a class="btn btn-info btn-xs '+saleOnBtnFlag+'" href="javascript:void(0)" onclick="saleOn(\'' + row.id + '\')"><i class="fa fa-check"></i>上架</a>');
						}
						return actions.join('');
					}
		        }]
		    };
		    $.table.init(options);
		});
	</script>
</body>
</html>